package com.zou.practice.rpc;

/**
 * 客户端测试
 *
 * @author zou
 */
public class ClientTest {
    public static void main(String[] args) {
        String serverAddress = "127.0.0.1";
        int serverPort = 4321;
        final RpcClient client = new RpcClient(serverAddress, serverPort);
        TransportMessage message = buildMessage("name1");
        Object result = client.sendAndReceive(message);
        System.out.println(result);
        message = buildMessage("name2");
        result = client.sendAndReceive(message);
        System.out.println(result);
    }

    private static TransportMessage buildMessage(String name) {
        String interfaceName = "com.rpc.service.HelloService";
        Class<?>[] paramsTypes = {String.class};
        Object[] parameters = {name};
        String methodName = "sayHello";
        TransportMessage message = new TransportMessage(interfaceName,
                methodName, paramsTypes, parameters);
        return message;
    }
}